package com.xbts.screen.controller.workshop;

import com.xbts.common.core.web.controller.BaseController;
import com.xbts.common.core.web.domain.AjaxResult;
import com.xbts.common.core.web.domain.BaseHistogramResult;
import com.xbts.common.core.web.domain.BasePieChartResult;
import com.xbts.common.security.annotation.RequiresPermissions;
import com.xbts.screen.domain.vo.WorkshopRateVO;
import com.xbts.screen.domain.workshop.vo.*;
import com.xbts.screen.service.IDrillService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

/**
 * 钻孔车间Controller
 */
@Api(tags = "钻孔车间")
@RestController
@RequestMapping("/drill")
public class DrillController extends BaseController {


    @Autowired
    private IDrillService drillService;

    /**
     * 实时达成率
     */
    @ApiOperation("实时达成率")
    @RequiresPermissions("workshop:drill:realTimeAchievementRate")
    @GetMapping("/realTimeAchievementRate")
    public AjaxResult realTimeAchievementRate(){
        RealTimeAchievementRateVO vo = drillService.realTimeAchievementRate();
        return success(vo);
    }
    /**
     * 近10天达成率
     */
    @ApiOperation("近10天达成率")
    @RequiresPermissions("workshop:drill:tenDaysAchievementRate")
    @GetMapping("/tenDaysAchievementRate")
    public AjaxResult tenDaysAchievementRate(){
        BaseHistogramResult result = drillService.tenDaysAchievementRate();
        return success(result);
    }
    /**
     * 达成率根据时间分组
     */
    @ApiOperation("达成率根据时间分组")
    @RequiresPermissions("workshop:drill:achievementRateGroupByTimeType")
    @GetMapping("/achievementRateGroupByTimeType")
    public AjaxResult achievementRateGroupByTimeType(){
        StatisticalRateGroupByTimeVO vo = drillService.achievementRateGroupByTimeType();
        return success(vo);
    }
    /**
     * 稼动率
     */
    @ApiOperation("稼动率")
    @RequiresPermissions("workshop:drill:utilizationRate")
    @GetMapping("/utilizationRate")
    public AjaxResult utilizationRate(){
        List<WorkshopRateVO> vos = drillService.utilizationRate();
        return success(vos);
    }
    /**
     * 电单耗
     */
    @ApiOperation("电单耗")
    @RequiresPermissions("workshop:drill:electricityUnitConsume")
    @GetMapping("/electricityUnitConsume")
    public AjaxResult electricityUnitConsume(){
        BaseHistogramResult result = drillService.electricityUnitConsume();
        return success(result);
    }
    /**
     * 排产计划
     */
    @ApiOperation("排产计划")
    @RequiresPermissions("workshop:drill:productionSchedule")
    @GetMapping("/productionSchedule")
    public AjaxResult productionSchedule(){
        List<ProductionScheduleVO> vos = drillService.productionSchedule();
        return success(vos);
    }
    /**
     * 周转率
     */
    @ApiOperation("周转率")
    @RequiresPermissions("workshop:drill:turnoverRate")
    @GetMapping("/turnoverRate")
    public AjaxResult turnoverRate(){
        BaseHistogramResult vo = drillService.turnoverRate();
        return success(vo);
    }
    /**
     * 周转率根据时间类型分组
     */
    @ApiOperation("周转率根据时间类型分组")
    @RequiresPermissions("workshop:drill:turnoverRateGroupByTimeType")
    @GetMapping("/turnoverRateGroupByTimeType")
    public AjaxResult turnoverRateGroupByTimeType(){
        StatisticalRateGroupByTimeVO vo = drillService.turnoverRateGroupByTimeType();
        return success(vo);
    }
    /**
     * 合格率
     */
    @ApiOperation("合格率")
    @RequiresPermissions("workshop:drill:passRate")
    @GetMapping("/passRate")
    public AjaxResult samplingPassRate(){
        return success(drillService.passRate());
    }
    /**
     * 不良统计
     */
    @ApiOperation("不良统计")
    @RequiresPermissions("workshop:drill:badStatistics")
    @GetMapping("/badStatistics")
    public AjaxResult samplingBadStatistics(){
        List<BasePieChartResult> resultList = drillService.badStatistics();
        return success(resultList);
    }
    /**
     * 合格率趋势
     */
    @ApiOperation("合格率趋势")
    @RequiresPermissions("workshop:finalInspection:passRateTrend")
    @GetMapping("/passRateTrend")
    public AjaxResult passRateTrend(){
        BaseHistogramResult result = drillService.passRateTrend();
        return success(result);
    }
    /**
     * 报废率
     */
    @ApiOperation("报废率")
    @RequiresPermissions("workshop:drill:scrapRate")
    @GetMapping("/scrapPassRate")
    public AjaxResult scrapPassRate(){
        return success(drillService.scrapRate());
    }
    /**
     * 报废统计
     */
    @ApiOperation("报废统计")
    @RequiresPermissions("workshop:drill:scrapStatistics")
    @GetMapping("/scrapStatistics")
    public AjaxResult PCS_scrapStatistics(){
        List<BasePieChartResult> resultList = drillService.scrapStatistics();
        return success(resultList);
    }
    /**
     * 料号批次合格率记录
     */
    @ApiOperation("料号批次合格率记录")
    @RequiresPermissions("workshop:drill:passRateRecord")
    @GetMapping("/passRateRecord")
    public AjaxResult passRateRecord(){
        List<PassRateRecordVO> resultList = drillService.passRateRecord();
        return success(resultList);
    }
}
